package com.leo;

import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.entity.SpawnData;
import com.leo.data.Rect;
import com.leo.entity.JsonEntityFactory;

import java.util.Optional;

import static com.almasb.fxgl.dsl.FXGL.getAssetLoader;
import static com.almasb.fxgl.dsl.FXGL.getGameWorld;
import static com.almasb.fxgl.dsl.FXGL.spawn;

/**
 * @Author: wangss
 * @CreateTime: 2023-06-14  22:16
 * @Description: TODO
 */
public class JsonApp extends GameApplication {
    @Override
    protected void initSettings(GameSettings settings) {

    }

    @Override
    protected void initGame() {
        getGameWorld().addEntityFactory(new JsonEntityFactory());
        Optional<Rect> rect = getAssetLoader().loadJSON("data/rect.json", Rect.class);
        Rect rect1 = rect.get();
        spawn("rect", new SpawnData().put("rect", rect1));

    }

    public static void main(String[] args) {
        launch(args);
    }
}
